package edu.uoc.tdp.client.pantalles;

import javax.swing.JPanel;
import java.awt.Frame;
import javax.swing.JDialog;
import javax.swing.WindowConstants;
import edu.uoc.tdp.client.comu.Util;
import edu.uoc.tdp.client.gestors.GestorAltaInscripcio;
import edu.uoc.tdp.comu.beans.EventInscripcions;
import javax.swing.JTextArea;
import java.awt.Rectangle;
import javax.swing.JButton;

public class PantallaAltaInscripcio extends JDialog {

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private GestorAltaInscripcio gestor;
	private JTextArea jTextArea = null;
	private JButton jButtonConfirmar = null;
	private JButton jButtonCancellar = null;

	public PantallaAltaInscripcio(Frame owner, EventInscripcions eventTriat) {
		super(owner);
		gestor = new GestorAltaInscripcio(this, eventTriat);
		initialize();
	}

	private void initialize() {
		this.setSize(424, 210);
		this.setLocationRelativeTo(null);
		this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		this.setResizable(false);
		this.setTitle(Util.GetEtiqueta("AltaInscripcio.TitolFinestra"));
		this.setModal(true);
		this.setContentPane(getJContentPane());
		this.rootPane.setDefaultButton(jButtonConfirmar);
		this.setVisible(true);
	}


	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getJTextArea(), null);
			jContentPane.add(getJButtonConfirmar(), null);
			jContentPane.add(getJButtonCancellar(), null);
		}
		return jContentPane;
	}


	private JTextArea getJTextArea() {
		if (jTextArea == null) {
			jTextArea = new JTextArea();
			jTextArea.setBounds(new Rectangle(16, 15, 392, 107));
			jTextArea.setOpaque(false);
			jTextArea.setBorder(null);
			jTextArea.setEditable(false);
			jTextArea.setText(gestor.OmplirDades());
		}
		return jTextArea;
	}


	private JButton getJButtonConfirmar() {
		if (jButtonConfirmar == null) {
			jButtonConfirmar = new JButton();
			jButtonConfirmar.setBounds(new Rectangle(200, 140, 101, 31));
			jButtonConfirmar.setText(Util.GetEtiqueta("AltaInscripcio.Boto.Confirmar"));
			jButtonConfirmar.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					gestor.ClickBotoConfirmar();
					dispose();
				}
			});
		}
		return jButtonConfirmar;
	}


	private JButton getJButtonCancellar() {
		if (jButtonCancellar == null) {
			jButtonCancellar = new JButton();
			jButtonCancellar.setBounds(new Rectangle(310, 140, 101, 31));
			jButtonCancellar.setText(Util.GetEtiqueta("AltaInscripcio.Boto.Cancellar"));
			jButtonCancellar.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					dispose();
				}
			});
		}
		return jButtonCancellar;
	}	
}
